
package org.apt.Bean;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;
import org.apt.connectDB.MyConnect;

/**
 *
 * @author MinhThang
 */
public class create_speaker_bean extends org.apache.struts.action.ActionForm {
    private String txtFullName;
    private String txtEmail;
    private  String txtDOB;
    private String txtMobile;
    private String txtAddress;
    private FormFile fileImage;
    public create_speaker_bean() {
        super();
        // TODO Auto-generated constructor stub
    }
    public boolean CreateSpeaker(){
        //Insert data to Speakers table
        Connection conn=null;
        PreparedStatement ps=null;
        String sql="Insert into Speakers(FullName,Image,Email,DOB,MobilePhone,Address,Status,Description) values(?,?,?,?,?,?,?,?)";
        FormFile file=null;
        file=getFileImage();
        try {
            conn=MyConnect.getConnection();
            ps=conn.prepareCall(sql);
            ps.setString(1, getTxtFullName());
            ps.setString(2, file.getFileName());
            ps.setString(3, getTxtEmail());
            ps.setString(4, getTxtDOB());
            ps.setString(5, getTxtMobile());
            ps.setString(6, getTxtAddress());
            ps.setBoolean(7, true);
            ps.setString(8, "");
            ps.executeUpdate();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        return false;
    }
    public String getTxtFullName() {
        return txtFullName;
    }

    /**
     * @param txtFullName the txtFullName to set
     */
    public void setTxtFullName(String txtFullName) {
        this.txtFullName = txtFullName;
    }

    /**
     * @return the fileImage
     */
    

    /**
     * @return the txtEmail
     */
    public String getTxtEmail() {
        return txtEmail;
    }

    /**
     * @param txtEmail the txtEmail to set
     */
    public void setTxtEmail(String txtEmail) {
        this.txtEmail = txtEmail;
    }

    /**
     * @return the txtDOB
     */
    public String getTxtDOB() {
        return txtDOB;
    }

    /**
     * @param txtDOB the txtDOB to set
     */
    public void setTxtDOB(String txtDOB) {
        this.txtDOB = txtDOB;
    }

    /**
     * @return the txtMobile
     */
    public String getTxtMobile() {
        return txtMobile;
    }

    /**
     * @param txtMobile the txtMobile to set
     */
    public void setTxtMobile(String txtMobile) {
        this.txtMobile = txtMobile;
    }

    /**
     * @return the txtAddress
     */
    public String getTxtAddress() {
        return txtAddress;
    }

    /**
     * @param txtAddress the txtAddress to set
     */
    public void setTxtAddress(String txtAddress) {
        this.txtAddress = txtAddress;
    }

    /**
     * @return the fileImage
     */
    public FormFile getFileImage() {
        return fileImage;
    }

    /**
     * @param fileImage the fileImage to set
     */
    public void setFileImage(FormFile fileImage) {
        this.fileImage = fileImage;
    }

    /**
     * @return the file
     */
    

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
   
}
